home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 8 / FM Towns Free Software Collection 8.iso / t_os / wink24h / src_h / wink2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-01  |  18.1 KB  |  679 lines

  1. /************************************************************
  2.  
  3.     FM-TOWNS Text Screen Editer Program
  4.  
  5.     1989.7.27   v1.00   Make By Ken
  6.  
  7. ************************************************************/
  8. #include    <stdio.h>
  9. #include    <stdlib.h>
  10. #include    <setjmp.h>
  11. #include    <string.h>
  12. #define MAIN
  13. #include    "defs.h"
  14.  
  15. #ifdef    FMR70
  16. #include    <signal.h>
  17. #endif
  18.  
  19. #ifdef  TOWNS
  20. #include    <egb.h>
  21. #include    <snd.h>
  22. #include    <fmcfrb.h>
  23. #include    <kkstr2.h>
  24. #define    unlink(f) remove(f)
  25. #endif
  26. /* ------------------ SIDEWORK 92.01.31 Pumpkin ------------- */
  27. #include    <mos.h>
  28. #include    <sidework.h>
  29. /* ---------------------------------------------------------- */
  30. /* ------------------ KYB init 92.03.20 Pumpkin ------------- */
  31. #include    "int24.h"
  32. /* ---------------------------------------------------------- */
  33. /* ------------------ Debug  92.02.07 Pumpkin --------------- */
  34. extern int  diskReady(int drive);
  35. extern    int    retdir(char *name);
  36. extern    int    chdir(char *name);
  37. /* ---------------------------------------------------------- */
  38. /* --------------- Color Pal   91.12.29 Pumpkin ------------- */
  39. void pal_init(char *pal_file);
  40. /* ---------------------------------------------------------- */
  41. unsigned int vramSeg,vramOffset;
  42.  
  43. /* ------------------ SIDEWORK 92.01.31 Pumpkin ------------- */
  44. char     *mwork;
  45. static    int vol,mute;
  46. /* ---------------------------------------------------------- */
  47.  
  48. /* ------------------ OAK4 91.12.28 Pumpkin ----------------- */
  49. /* ------------------ OAK4 92.12.28 Pumpkin ----------------- */
  50. #include    <dos.h>
  51. int modeW = KAN_EISYOU | KAN_EISUU | KAN_HANKAKU;
  52. /* ---------------------------------------------------------- */
  53. /* ------------------ CD No Stop 91.10.18 Pumpkin ----------- */
  54. #ifdef    TOWNS
  55. extern     int    cd_stop;
  56. #endif
  57. /* ---------------------------------------------------------- */
  58. extern     int    video_flg;
  59.  
  60. /* --------------------- EUP play 92.03.30 ------------------ */
  61. #ifdef    TOWNS
  62. char     *swork;
  63. #define BUFF_SIZE (66000)    /* customaized by YAMA */
  64. extern int ML_Start( char * ,int , char * );
  65. extern int ML_End();
  66. extern char buff[];
  67. #endif
  68. /* ---------------------------------------------------------- */
  69.  
  70. extern void wrtstr();
  71. extern void Dsp_ins_mode();
  72. extern void Dsp_free();
  73. extern void Ins_buf();
  74. extern void Cut_buf();
  75. extern int  Dsp_init();
  76. extern int  Bfp_init();
  77. extern void Set_vram();
  78. extern void Dsp_vram();
  79. extern BOOL edit();
  80. extern int  Del_wind();
  81. extern void Bfp_end();
  82. extern void RSB_end();
  83. extern void Dmy_form();
  84. extern void Del_buf();
  85. extern void Auto_log_init();
  86. extern void CD_endof();
  87.  
  88. extern UCHAR vram[];
  89. extern char  *SPCSTR;
  90. extern char  *Auto_log_file;
  91.  
  92. /* ------------------ OAK4 91.12.28 Pumpkin ----------------- */
  93. /*******
  94. extern short int modeW;
  95. *******/
  96. /* ---------------------------------------------------------- */
  97.  
  98.     char     *work;
  99.     jmp_buf mark;
  100.     char    *file_name=NULL;
  101.     char    *Tmp_device_name=NULL;
  102.  
  103. static BOOL    old_wrt_flg=ERR;
  104. static char     tmp_name[160];
  105. static int    Back_up = FALSE;
  106. static int    Apend_Z = FALSE;
  107.  
  108. void    Start_Msg()
  109. {
  110.     static char *msg[]={
  111.     "           WINK @ー            ",
  112.     "   Multi Screen Text Editor   ",
  113.     "    WINK海賊版[ver1.24H]  ",
  114.     " Copyright (c) 1989-94 FTOWNS ",
  115.     "    Created by K.Miyazaki     ",
  116.     "       thanks to RED++        ",
  117.     "    customaized by Pumpkin    ",
  118.     NULL
  119.     };
  120.     int     i;
  121.     char    tmp[160];
  122.  
  123.     Dmy_form(tmp,30,0x98,0x95,0x99); 
  124.     wrtstr(tmp,20+24,9+9,0x07);
  125.     Dmy_form(tmp,30,0x96,0x20,0x96); 
  126.     for ( i = 0 ; msg[i] != NULL ; i++ ) {
  127.         wrtstr(tmp,20+24,10+i+9,0x07);
  128.         wrtstr(msg[i],21+24,10+i+9,i == 0 ? 0x14 : 0x07);
  129.     }
  130.     Dmy_form(tmp,30,0x9A,0x95,0x9B); 
  131.     wrtstr(tmp,20+24,17+9,0x07);
  132.     wrtstr("WINK",25+24,12+9,0x16);
  133. }
  134.  
  135. void    GetDspPos(int *x, int *y)
  136. {
  137.     *x = (OFF_X + Cur_X) * 8;
  138.     *y = (OFF_Y + Cur_Y) * 16;
  139. }
  140.  
  141. void    Tango_Touroku(char *str);
  142.  
  143. /* ------------------ OAK4 91.12.28 Pumpkin ----------------- */
  144. void    Gra_init(int kan_sw)
  145. /*****
  146. void    Gra_init()
  147. ******/
  148. /* ---------------------------------------------------------- */
  149. {
  150. #ifdef    TOWNS
  151.     KANJ    kana;
  152.     RESOLUTION    para;
  153. /* ------------------ OAK4 91.12.28 Pumpkin ----------------- */
  154.     static union REGS    reg;
  155.     int     col[16];
  156. /* ---------------------------------------------------------- */
  157.  
  158.     work = (char *)malloc(EgbWorkSize);
  159.     memset(work,0,EgbWorkSize);
  160. /* --------------------- EUP play 92.03.30 ------------------ */
  161.     swork = (char *)malloc(16384);        /* customaized by YAMA */
  162.     memset(swork,0,16384);            /* customaized by YAMA */
  163. /* ---------------------------------------------------------- */
  164.     EGB_init(work,EgbWorkSize);
  165.     EGB_resolution(work, 0, 23);
  166.     EGB_resolution(work, 1, 25);
  167.     EGB_displayPage(work, 0, 3);
  168.     EGB_writePage(work,0);
  169.     EGB_getResolutionPage( 0,¶ );
  170.     vramSeg = para.segment;
  171.     vramOffset = (unsigned int)para.offset;
  172.  
  173.     EGB_pen(work,0);
  174.     EGB_penSize(work,1);
  175. /* ------------------ SIDEWORK 92.02.14 Pumpkin ------------- */
  176.     SND_elevol_read(1,&vol,&vol);
  177.     SND_get_elevol_mute(&mute);
  178. /* ---------------------------------------------------------- */
  179. /* --------------------- EUP play 92.03.30 ------------------ */
  180.     SND_init(swork);            /* customaized by YAMA */
  181. /* ---------------------------------------------------------- */
  182. /* ------------------ SIDEWORK 92.02.14 Pumpkin ------------- */
  183.     SND_elevol_set(1,vol,vol);
  184.     SND_elevol_mute(mute | 0x33);
  185. /******
  186.     SND_elevol_init();
  187.     SND_elevol_mute(0x30);
  188.     SND_elevol_set(1,64,64);
  189. ******/
  190. /* ---------------------------------------------------------- */
  191. /* --------------------- EUP play 92.03.30 ------------------ */
  192.     ML_Start(buff,BUFF_SIZE,swork);        /* customaized by YAMA */
  193. /* ---------------------------------------------------------- */
  194.  
  195.     kana.scrn   = KAN_SCRN16;   /*  画面モードは16色モード               */
  196.     kana.egbw   = work;         /*  EGBのワークアドレスを設定する            */
  197.     kana.wPage  = 0;            /*  表示ページを0にする                */
  198.     kana.mosAp  = KAN_MOSON;    /*  マウスの制御をする                 */
  199.     kana.gets   = Tango_Touroku;/*  文字取得ルーチンの設定                 */
  200.     kana.getPos = GetDspPos;    /*  未確定文字列表示位置取得関数の設定 */
  201.     kana.maxX   = 1023;          /*  画面の最大X座標                    */
  202.     kana.maxY   = 767;          /*  画面の最大Y座標                    */
  203.  
  204.     KAN_prepare(&kana);
  205.  
  206. /* ------------------ OAK4 91.12.28 Pumpkin ----------------- */
  207.     /*  従来のWINKライクなカラーテーブルの設定 */
  208.     col[ 0] = 0x0f;
  209.     col[ 1] = 0x01;
  210.     col[ 2] = 0x02;
  211.     col[ 3] = 0x03;
  212.     col[ 4] = 0x04;
  213.     col[ 5] = 0x05;
  214.     col[ 6] = 0x06;
  215.     col[ 7] = 0x00;
  216.     col[ 8] = 0x08;
  217.     col[ 9] = 0x09;
  218.     col[10] = 0x0a;
  219.     col[11] = 0x0b;
  220.     col[12] = 0x04;
  221.     col[13] = 0x06;
  222.     col[14] = 0x03;
  223.     col[15] = 0x01;
  224.     KAN_setClrTbl( col);
  225.  
  226. /* ---------------------------------------------------------- */
  227.     KAN_disp(KAN_DISPON);
  228.  
  229. /* ------------------ OAK4 91.12.28 Pumpkin ----------------- */
  230. /* ------------------ OAK4 92.12.28 Pumpkin ----------------- */
  231.     /* OAK入力モード設定 */
  232.  
  233.     if (kan_sw != FALSE) {
  234.     KAN_setMode(modeW);
  235.     }
  236. /* ---------------------------------------------------------- */
  237.  
  238.  
  239. #endif
  240. }
  241. void    Dsp_file_name()
  242. {
  243.     char    tmp[160];
  244.  
  245.     memset(tmp,' ',60); tmp[60] = '\0';
  246.     wrtstr(tmp,0,1,0x1F);
  247.     if ( file_name != NULL ) {
  248.     sprintf(tmp," %-12s ",file_name);
  249.     wrtstr(tmp,0,1,0x14);
  250.     } else
  251.     wrtstr("  [Not File]  ",1,1,0x1F);
  252. }
  253. void    Dsp_wrt_flg()
  254. {
  255.     if ( Wrt_flg != old_wrt_flg ) {
  256.     if ( (old_wrt_flg = Wrt_flg) == FALSE )
  257.         wrtstr("表示",0,0,0x17);
  258.     else
  259.         wrtstr("編集",0,0,0x17);
  260.     }
  261. }
  262. void    Dsp_PFKEY()
  263. {
  264.     int     i;
  265.     UCHAR   tmp[200];
  266.  
  267.     static char *menu[]={
  268.     " MENU1"," MENU2"," MENU3"," MENU4","CD演奏",
  269.     " 選択 "," 削除 "," 確定 "," 複写 "," 通信 " };
  270.  
  271.     for ( i = 0 ; i < 10 ; i++ )
  272.         wrtstr(menu[i],i*7+(i/5),MENU_Y,0x1F);
  273.  
  274.     memset(tmp,' ',47); tmp[48] = '\0';
  275.     wrtstr(tmp,71,MENU_Y,0x1F);
  276. }
  277. void    Dsp_status()
  278. {
  279.     UCHAR   tmp[200];
  280.  
  281.     memset(tmp,' ',128); tmp[128] = '\0';
  282.     wrtstr(tmp,0,0,0x1F);
  283.     wrtstr(tmp,0,1,0x1F);
  284.     Dsp_ins_mode();
  285.     Dsp_file_name();
  286.     Dsp_wrt_flg();
  287.     Dsp_free();
  288.     Dsp_PFKEY();
  289. }
  290. int     Buf_init(file)
  291. char    *file;
  292. {
  293.     int        n;
  294.     FILE    *fp;
  295.     UCHAR   tmp[512];
  296.  
  297.     top_ptr = lin_ptr = ent_ptr = btm_ptr = 0;
  298.     if ( file != (char *)NULL && (fp = fopen(file,"rb")) != (FILE *)NULL ) {
  299.     wrtstr("ファイルを読み込んでいます",30,1,0x15);
  300.     while ( (n = fread(tmp,1,512,fp)) > 0 ) {
  301.         Ins_buf(btm_ptr,n,tmp);
  302.         btm_ptr += n;
  303.     }
  304.     if ( btm_ptr > 0 && *Cnv_ptr(btm_ptr-1) == '\x1A' )
  305.         Del_buf(--btm_ptr,1L);
  306.     file_name = file;
  307.     fclose(fp);
  308.     wrtstr(SPCSTR,30,1,0x1F);
  309.     } else
  310.     file_name = file;
  311.  
  312.     chk_ptr = cke_ptr = ERR;
  313.     Wrt_flg = FALSE;
  314.     old_wrt_flg = TRUE;
  315.  
  316.     return FALSE;
  317. }
  318. int    save(file)
  319. char    *file;
  320. {
  321.     FILE    *fp;
  322.     UCHAR   tmp[256];
  323.     int        n;
  324.     LONG    sp,sz;
  325.     char    *p;
  326.  
  327.     if ( file != NULL ) {
  328.     file_name = file;
  329.     Dsp_file_name();
  330.     }
  331.     if ( file_name == NULL )
  332.     return ERR;
  333.  
  334.     if ( Back_up != FALSE ) {
  335.     strcpy((char *)tmp,file_name);
  336.     if ( (p = strrchr((char *)tmp,'.')) == NULL )
  337.         for ( p = (char *)tmp ; *p != '\0' ; p++ );
  338.     strcpy(p,".BAK");
  339.     unlink((char *)tmp);
  340.     rename(file_name,(char *)tmp);
  341.     }
  342.  
  343.     if ( (fp = fopen(file_name,"wb")) == NULL )
  344.     return ERR;
  345.  
  346.     for ( sp = 0,sz = btm_ptr ; sz > 0 ; ) {
  347.     if ( sz < 256 ) n = sz; else n = 256;
  348.         Cut_buf(tmp,n,sp);
  349. /* ------------------ bug fix  93.02.18 Pumpkin ---------------- */
  350.     if (fwrite(tmp,1,n,fp) == 0) break;
  351. /* -------------------------------------------------------------- */
  352. /**********
  353.     fwrite(tmp,1,n,fp);
  354. **********/
  355.     sp += n;
  356.     sz -= n;
  357.     }
  358.  
  359.     if ( Apend_Z == FALSE ) {
  360.     tmp[0] = 0x1A;
  361.     fwrite(tmp,1,1,fp);
  362.     }
  363.  
  364.     if ( ferror(fp) ) {
  365.     fclose(fp);
  366.     return ERR;
  367.     }
  368.     fclose(fp);
  369.     return FALSE;
  370. }
  371. void    Set_file_name(file)
  372. char    *file;
  373. {
  374.     strcpy(tmp_name,file);
  375.     file_name = tmp_name;
  376.     Dsp_file_name();
  377. }
  378. void    Set2_file_name(file)
  379. char    *file;
  380. {
  381.     strcpy(tmp_name,file);
  382.     file_name = tmp_name;
  383. }
  384. void    main(argc,argv)
  385. int    argc;
  386. char    *argv[];
  387. {
  388.     int     i;
  389.     char    tmp[40];
  390.     char    *p;
  391.     char    *file=NULL;
  392.  
  393.     CONTRL = 0;
  394.     TAB = 8;
  395. /* ------------------ Debug  92.02.07 Pumpkin --------------- */
  396.     char    firstdir[128];
  397. /* ---------------------------------------------------------- */
  398. /* ------------------ OAK4 91.12.28 Pumpkin ----------------- */
  399.     int kan_mode = FALSE;
  400. /* ---------------------------------------------------------- */
  401. /* --------------- Color Pal   91.08.28 Pumpkin ------------- */
  402.     char    *pal_file = NULL;
  403. /* ---------------------------------------------------------- */
  404. /* ------------------ KYB init 92.03.20 Pumpkin ------------- */
  405.     int     mojip[22][2];
  406.     char moji[22][20];
  407.  
  408.     set24h();
  409. /* ---------------------------------------------------------- */
  410. /* ------------------ Debug  92.02.07 Pumpkin --------------- */
  411.     retdir(firstdir);
  412. /* ---------------------------------------------------------- */
  413.  
  414. #ifdef    FMR70
  415.     signal(SIGINT,SIG_IGN);
  416. #endif
  417.  
  418.     while ( --argc > 0 ) {
  419.     p = *(++argv);
  420.     if ( *p == '-' || *p == '/' ) {
  421.         switch(*(++p)) {
  422.         case 'A': case 'a':
  423.             Auto_log_file = ++p;
  424.             break;
  425.         case 'B': case 'b':
  426.             Back_up = TRUE;
  427.             break;
  428.         case 'Z': case 'z':
  429.             Apend_Z = TRUE;
  430.             break;
  431. /* ------------------ OAK4 91.12.28 Pumpkin ----------------- */
  432.         case 'R': case 'r':
  433.                 kan_mode = TRUE;
  434.                 modeW = modeW & ~0x30l;
  435.                 modeW = modeW | KAN_ROUMAZI;
  436.             break;
  437.         case 'F': case 'f':
  438.                 kan_mode = TRUE;
  439.                 modeW = modeW & ~0xc0l;
  440.                 modeW = modeW | KAN_ZENKAKU;
  441.             break;
  442.         case 'K': case 'k':
  443.                 kan_mode = TRUE;
  444.                 modeW = modeW & ~0x700l;
  445.                 modeW = modeW | KAN_KATAKANA;
  446.             break;
  447.         case 'H': case 'h':
  448.                 kan_mode = TRUE;
  449.                 modeW = modeW & ~0x700l;
  450.                 modeW = modeW | KAN_HIRAGANA;
  451.             break;
  452.         case 'C': case 'c':
  453.                 kan_mode = TRUE;
  454.                 modeW = modeW & ~0x20000l;
  455.                 modeW = modeW | KAN_EIDAI;
  456.             break;
  457. /* ---------------------------------------------------------- */
  458. /**************************************************
  459.         case 'R': case 'r':
  460.             modeW = (modeW & 0xFFF3) | 0x0008;
  461.             break;
  462.         case 'F': case 'f':
  463.             modeW = (modeW & 0xFFCF) | 0x0020;
  464.             break;
  465.         case 'K': case 'k':
  466.             modeW = (modeW & 0xFE3F) | 0x0080;
  467.             break;
  468.         case 'H': case 'h':
  469.             modeW = (modeW & 0xFE3F) | 0x0100;
  470.             break;
  471. **************************************************/
  472.         case 'T': case 't':
  473.             Tmp_device_name = ++p;
  474.             break;
  475.         case 'D': case 'd':
  476.             TAB = atoi(++p);
  477.             break;
  478. /* --------------- Color Pal   91.08.28 Pumpkin ------------- */
  479. #ifdef    TOWNS
  480.         case 'P': case 'p':
  481.             pal_file = ++p;
  482.             break;
  483. #endif
  484. /* ---------------------------------------------------------- */
  485. /* ------------------ CD No Stop 91.10.18 Pumpkin ----------- */
  486. #ifdef    TOWNS
  487.         case 'N': case 'n':
  488.             cd_stop = FALSE;
  489.             break;
  490. #endif
  491.  
  492. /* ---------------------------------------------------------- */
  493.  
  494.  
  495.         }
  496.     } else
  497.         file = p;
  498.     }
  499.  
  500. /* ------------------ OAK4 91.12.28 Pumpkin ----------------- */
  501.     Gra_init(kan_mode);
  502. /*******
  503.     Gra_init();
  504. *******/
  505. /* ---------------------------------------------------------- */
  506. /* --------------- Color Pal   91.08.28 Pumpkin ------------- */
  507. #ifdef    TOWNS
  508.     pal_init(pal_file);
  509. #endif
  510. /* ---------------------------------------------------------- */
  511. /* --------------- RSB for L20 92.12.27 Pumpkin ------------- */
  512.     RSB_start();
  513. /*******
  514.     RSB_Init();
  515. *******/
  516.     Dsp_init();
  517. /* ------------------ KYB init 92.03.20 Pumpkin ------------- */
  518.     for (i=1;i<21;i++) 
  519.         KYB_rdasign(&mojip[i][1],0x8000+i,&mojip[i][0],&moji[i][0]);
  520.     KYB_rdasign(&mojip[21][1],0x7f,&mojip[21][0],&moji[21][0]);
  521.     KYB_asign(0,0x7f,1,"\x7f");
  522.     KYB_setbuf(1);
  523. /********
  524.     KYB_clic(1);
  525. ********/
  526. /* ---------------------------------------------------------- */
  527.     Auto_log_init();
  528.     Dsp_status();
  529.     Start_Msg();
  530.  
  531.     if ( Bfp_init() != FALSE ) {
  532.     wrtstr("メモリ管理の初期化に失敗しました",30,1,0x12);
  533.     exit(0);
  534.     }
  535.     if ( Buf_init(file) != FALSE ) {
  536.     wrtstr("ファイルの初期化に失敗しました",30,1,0x12);
  537.     exit(0);
  538.     }
  539.  
  540.     Dsp_status();
  541.     Set_vram();
  542.     Dsp_vram(vram);
  543.  
  544.     if ( (i = setjmp(mark)) != 0 ) {
  545.     sprintf(tmp,"致命的なエラ-が発生しました #%d",i);
  546.     wrtstr(tmp,30,1,0x12);
  547.     }
  548.  
  549. /* ------------------ SIDEWORK 92.01.31 Pumpkin ------------- */
  550.     mwork = (char *)malloc(4096);
  551.     MOS_start(mwork,4096);
  552.     sdk_control(0);    /* ホットキーによるサイドワーク起動の禁止 */
  553. /* ---------------------------------------------------------- */
  554.  
  555.     do {
  556.         while ( edit() == FALSE );
  557.     } while ( Del_wind() == FALSE );
  558.  
  559. /* --------------------- EUP play 92.03.30 ------------------ */
  560.     ML_End();                /* customaized by YAMA */
  561. /* ---------------------------------------------------------- */
  562.     Bfp_end();
  563.     RSB_end();
  564. /* ------------------ KYB init 92.03.20 Pumpkin ------------- */
  565.     KYB_init();
  566.     for (i=1;i<21;i++) 
  567.         KYB_asign(mojip[i][1],0x8000+i,mojip[i][0],&moji[i][1]);
  568.     KYB_asign(mojip[21][1],0x7f,mojip[21][0],&moji[21][1]);
  569. /* ---------------------------------------------------------- */
  570.     KYB_clic(1);
  571.  
  572. #ifdef    TOWNS
  573.     if (video_flg) VC_off();
  574.     CD_endof();
  575. /* ------------------ SIDEWORK 92.01.31 Pumpkin ------------- */
  576.     MOS_end();
  577.     free(mwork);
  578. /* ---------------------------------------------------------- */
  579. /* --------------------- EUP play 92.03.30 ------------------ */
  580.     SND_end();                /* customaized by YAMA */
  581. /* ---------------------------------------------------------- */
  582.     KAN_disp(KAN_DISPOFF);
  583.     KAN_finish();
  584.     RSB_End();
  585. /* --------------- Color Pal   91.12.29 Pumpkin ------------- */
  586.     EGB_init(work,EgbWorkSize);
  587. /* ---------------------------------------------------------- */
  588. #endif
  589. /* ------------------ Debug  92.02.07 Pumpkin --------------- */
  590.     if (diskReady(firstdir[0] - 'A' + 1) == FALSE) 
  591.         chdir(firstdir);
  592.     reset24h();
  593. /* ---------------------------------------------------------- */
  594.  
  595. #ifdef    FMR70
  596.     cprintf("\x1B[2J");
  597. #endif
  598. }
  599.  
  600. #ifdef    FMR70
  601. #include    <dos.h>
  602.  
  603. int     KYB_clic(sw);
  604. int    sw;
  605. {
  606.     union REGS    regs;
  607.  
  608.     regs.h.ah = 0x05;
  609.     regs.h.al = sw;
  610.     int86(0x90,®s,®s);
  611.     return;
  612. }
  613. int    kbhit()
  614. {
  615.     union REGS    regs;
  616.  
  617.     regs.h.ah = 0x07;
  618.     int86(0x90,®s,®s);
  619.     return (int)regs.h.al;
  620. }
  621. int    KYB_read(sw,ec)
  622. int    sw;
  623. unsigned *ec;
  624. {
  625.     union REGS    regs;
  626.  
  627.     regs.h.ah = 0x09;
  628.     regs.h.al = sw;
  629.     int86(0x90,®s,®s);
  630.     *ec = regs.x.bx;
  631.     if ( *ec >= 0x5D00 && *ec <= 0x6600 ) {
  632.         regs.h.ah = 0x09;
  633.         regs.h.al = sw;
  634.         int86(0x90,®s,®s);
  635.         *ec = regs.x.bx;
  636.     }
  637.     return regs.x.dx;
  638. }
  639. #endif
  640.  
  641. /* --------------- Color Pal   91.08.28 Pumpkin ------------- */
  642. /* --------------- Color Pal   91.12.29 Pumpkin ------------- */
  643. #ifdef TOWNS
  644. void pal_init(char *pal_file)
  645. {
  646.     int        n=0,r=0,g=0,b=0,i,num;
  647.     FILE *pfp;
  648.  
  649.     struct _pal_body {
  650.         long    num;
  651.         char    dat[8*16];
  652.     } pal_body;
  653.  
  654.  
  655.     if (pal_file == NULL) return;
  656.     EGB_getPalette(0,(char *)&pal_body);
  657.  
  658.     if ( (pfp = fopen(pal_file,"r")) != NULL ) {
  659.     if (fscanf( pfp, "%d",&num ) == 1 &&  num>0 && num<17 ) {
  660.         for(i=0; i<num; i++) {
  661.                 fscanf( pfp, "%d %d %d %d",&n,&b,&r,&g ); 
  662.             if ( n<16 ) {
  663.             pal_body.dat[n*8  ] = (long)n;
  664.             pal_body.dat[n*8+4] = (char)b*16;
  665.             pal_body.dat[n*8+5] = (char)r*16;
  666.             pal_body.dat[n*8+6] = (char)g*16;
  667.             }
  668.             }
  669.         }
  670.     fclose( pfp );
  671.     }
  672.     EGB_writePage(work, 0);
  673.     EGB_palette(work,1,(char *)&pal_body);
  674.  
  675. }
  676.  
  677. #endif
  678. /* ---------------------------------------------------------- */
  679.